// components/answer-item/index.js
Component({
	properties: {
		answer: Object,
		idx: Number
	},
	data: {

	},
	methods: {
		onGotoAnswer() {
			if (this.properties.answer.prePercent !== null) {
				if (this.properties.answer.user_activity_logs.length >= 3) {
					wx.showToast({
						icon: "none",
						title: '您本关卡已经答题三次,已经失去答题机会',
						duration: 3000
					})
				}else {
					if (this.properties.answer.prePercent >= 0.6) {
						wx.navigateTo({
							url: `/pages/exercise/exercise?cpid=${this.properties.answer.id}&count=${(this.properties.idx + 1) * 5}`
						})
					}else {
						wx.showToast({
							icon: "none",
							title: '上一关正确率未达到60%',
							duration: 3000
						})
					}
				}
			}else {
				wx.navigateTo({
					url: `/pages/exercise/exercise?cpid=${this.properties.answer.id}&count=${(this.properties.idx + 1) * 5}`
				})
			}
		}
	}
})
